-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: auth-req caching #4278
feat: auth-req caching #4278
Conversation
Welcome @moolen! |
Hi @moolen. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
4a495bb
to
255ece5
Compare
@moolen please add e2e tests |
/ok-to-test |
/hold |
Codecov Report
@@ Coverage Diff @@
## master #4278 +/- ##
==========================================
+ Coverage 58.3% 58.47% +0.16%
==========================================
Files 87 87
Lines 6478 6528 +50
==========================================
+ Hits 3777 3817 +40
- Misses 2274 2282 +8
- Partials 427 429 +2
Continue to review full report at Codecov.
|
/retest |
@moolen two comments:
|
@aledbf Thanks for your feedback!
good catch, that makes sense!
You're right, it should be a list to allow configuration of multiple durations. But while i think about that i'm not really sure if we really need this annotation at all. The user could set I'll implement it as a list for now. If you like using
It depends on the user's context i would say. For my use-case ($corp internal web-apps) i use I'd propose to lower the default value to |
b23ec18
to
d4c3553
Compare
i did touch this; The last runs indicate this test is flaky; let's retest and maybe dig deeper. |
👍
👍 Also, please squash the commits |
d4c3553
to
1262b85
Compare
/approve |
should it include location identifier too? since one can configure different external authentication for different locations in the same server. |
1262b85
to
67647c2
Compare
again, that flaky test :/ |
Apologies for that :( |
@ElvinEfendi i added the location identifier and squashed the commits. |
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any way to not duplicate this logic? @aledbf do we have means to share code between here and annotation? like a utils package or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I centralized the "parsing" logic for now in d6b9014. Let me know if you want it in a utils package. I digged into this topic - it seems there's a bunch of code that is copy/pasted with slight adaptions (e.g. returning vs. logging an error).
Can you add a test to assert that the cache key includes location and server identifiers? For location the test would like like this
|
Thanks for your feedback! I added tests to verify the scope of the cache key (location/server) and addressed the other comments too. |
9071d9e
to
836a5fd
Compare
/test pull-ingress-nginx-e2e-1-12 |
@@ -378,6 +380,10 @@ Additionally it is possible to set: | |||
`<Response_Header_1, ..., Response_Header_n>` to specify headers to pass to backend once authentication request completes. | |||
* `nginx.ingress.kubernetes.io/auth-request-redirect`: | |||
`<Request_Redirect_URL>` to specify the X-Auth-Request-Redirect header value. | |||
* `nginx.ingress.kubernetes.io/auth-cache-key`: | |||
`<Cache_Key>` this enables caching for auth requests. specify a lookup key for auth responses. e.g. `$remote_user$http_authorization`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make a note that this will be hashed and encoded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the implementation details are not important - the mechanics are tho!
I appended this:
Each server and location has it's own keyspace. Hence a cached response is only valid on a per-server and per-location basis
@moolen this is looking great! Once you squash the commits we can merge this. |
add a way to configure the `proxy_cache_*` [1] directive for external-auth. The user-defined cache_key may contain sensitive information (e.g. Authorization header). We want to store *only* a hash of that key, not the key itself on disk. [1] http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_cache_key Signed-off-by: Moritz Johner <[email protected]>
836a5fd
to
23504db
Compare
/test pull-ingress-nginx-e2e-1-12 |
/lgtm thanks @moolen ! |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aledbf, ElvinEfendi, moolen The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hey a quick one - thanks for all your effort in this everyone, finally able to rid it of my monkeypatch |
Isn't this dangerous in the case where the user specified cache key ends up being an empty variable? E.g. if the cache key is set to |
What this PR does / why we need it:
This PR adds a way to configure the
proxy_cache_*
(docs) directive for external authentication.It adds these annotations, as proposed by @Stono in #2862 :
nginx.ingress.kubernetes.io/auth-cache-key
nginx.ingress.kubernetes.io/auth-cache-duration
The first one sets the
proxy_cache_key
(e.g.$uri$cookie__auth_proxy
) and enables the feature. The latter sets the cache duration (defaults to10m
)Note:
The user-defined
cache_key
may contain sensitive information (e.g.Authorization
header). That's why we want to store only a hash of that key, not the key itself on disk.fixes #2862